package com.hroay.netty02.fake;

import com.hroay.netty02.bio.TimeServer;
import com.hroay.netty02.bio.TimeServerHandler;
import lombok.extern.slf4j.Slf4j;

import java.net.Socket;

/**
 * @author heyingcheng
 * @category Class description
 * @email heyingcheng@ctvit.com.cn
 * @date 2018/2/1 16:36
 */
@Slf4j
public class TimeServerThreadPool extends TimeServer {

    private TimeServerHandlerThreadPool threadPool;

    public TimeServerThreadPool(int port) {
        super(port);
    }

    @Override
    public void initTask() {
        threadPool = new TimeServerHandlerThreadPool(50, 10000);
    }

    @Override
    public void startTask(Socket socket) {
        threadPool.execute(new TimeServerHandler(socket));
    }

    public static void main(String[] args) {
        TimeServer timeServer = new TimeServerThreadPool(9999);
        timeServer.startServer();
    }

}
